package com.mice.game.trigger
{
	import com.mice.game.core.Fighter;

	public class DamageTrigger{
		private static var _instance:DamageTrigger;
		
		/**
		 * 攻击者列表
		 */
		private var _attackerList:Array = new Array();
		
		public function DamageTrigger(){}
		
		public static function get instance():DamageTrigger{
			if (_instance == null)
				_instance = new DamageTrigger();
			return _instance;
		}
		
		/**
		 * 添加攻击者到列表
		 */		
		public function addAttacker(attacker:Fighter):void{
			_attackerList.push(attacker);
		}
		
		public function update():void{
			var wolf:Fighter;
			for (var i:int = (_attackerList.length - 1); i >= 0; i--){
				wolf = _attackerList[i] as Fighter;
				if (wolf.isDead || wolf.isRun){
					_attackerList.splice(i, 1);
					continue;
				}
				
				wolf.waitToContinueAttack();
			}
		}
	}
}